/*#include<iostream>
#include<unistd.h>
#include<pthread.h>

using namespace std;

int g_val=100;

void show (const string name)
{
    cout<<name<<"say#"<<"hello thread"<<endl;
}

//new thread
void *threadRoutine(void* args)
{
    while(1)
    {
        printf("new thread pid:%d,g_val:%d,&g_val:0x%p\n",getpid(),g_val,&g_val);
        //cout<<"new thread,pid:"<<getpid()<<endl;
        //show("[new thread]");
        sleep(1);
    }
}
 
int main()
{
    // cout<<sizeof(void)<<endl;
    // cout<<sizeof(void*)<<endl;
    pthread_t tid;
    pthread_create(&tid,nullptr,threadRoutine,nullptr);//不是系统调用。
    
    while(true)
    {
        printf("main thread pid:%d,g_val:%d,&g_val:0x%p\n",getpid(),g_val,&g_val);

        //cout<<"main thread,pid:"<<getpid()<<endl;
        //show("[main thread]");
        sleep(1);
        g_val++;
    }

    return 0;
}*/

#include<iostream>
#include<unistd.h>
#include<pthread.h>

using namespace std;

//new thread
void *threadRoutine(void* args)
{
    while(1)
    {
        cout<<"new thread,pid:"<<getpid()<<endl;
        sleep(1);
    }
}
 
int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,threadRoutine,nullptr);//不是系统调用。
    
    while(true)
    {
        cout<<"main thread,pid:"<<getpid()<<",myIDis:"<<pthread_self()<<endl;
        sleep(1);
    }

    return 0;
}